import React from 'react'
import { Route, Redirect } from 'react-router-dom'
import { getState } from 'common/state'

/**
 * 受保护route
 * 登录验证 没有登录会跳转到登陆组件
 * @returns 
 */
export default function ProtectedRoute({ component: Component, ...rest } = {}) {
    if (getState('isLogin')) {
        return <Route {...rest} component={Component} />
    } else {
        return <Redirect to="/login" />
    } 
}
